var images = ["my_likafu/image/lunbo1.jpg", "my_likafu/image/lunbo2.jpg", "my_likafu/image/lunbo3.jpg", "my_likafu/image/lunbo4.jpg", "my_likafu/image/lunbo5.jpg", "my_likafu/image/lunbo6.jpg"];


var index = 0;

function carousel() {
    var image = document.getElementById("image_main");
    image.src = images[index++];
    if (index >= 6) {
        index = 0;
    }
}

setInterval(carousel, 2500);

var flag = true;

function changeCollectin() {
    var coll = document.getElementById("collection");

    if (flag) {
        coll.src = "my_likafu/image/shoucang_hong.png";
        flag = false;
    } else {
        coll.src = "my_likafu/image/shoucang.png";
        flag = true;
    }
}

function page() {
    window.top.location.href = "IndexServlet";
}

function del() {
    var p = document.getElementById("num");
    if (parseInt(p.innerText) > 1) {
        p.innerText = parseInt(p.innerText) - 1
    }
}
function add() {
    var p = document.getElementById("num");
    p.innerText = parseInt(p.innerText) + 1
}
function purchase(id) {
    var shop = document.getElementById("goshop");
    var num = document.getElementById("num").innerHTML;
    console.log(num)

    if (shop.style.display === "") {
        shop.style.display = "block"
    } else {
        window.location.href = "SubmitOrderServlet?id="+id+"&num="+num;
    }
}